package  
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import ScreensManager.GameScreens.EditorScreen;
	import ScreensManager.GameScreens.GameScreen;
	import ScreensManager.GameScreens.Intro;
	import ScreensManager.GameScreens.MainMenu;
	import ScreensManager.Screen;
	import ScreensManager.Screens;
	import Utils.Time;
	/**
	 * ...
	 * @author Danilo Gama
	 */
	public class Main extends MovieClip
	{
		public static var _Instance:Main;
		private static var currentScreen:Screen;
		
		public function Main() 
		{
			_Instance = this;
			
			ChangeScreen(Screens.INTRO);
			
			addEventListener(Event.ENTER_FRAME, update, false, 0, true);
		}
		
		public static function getInstance():Main
		{
			return _Instance;
		}
		
		private function onClick(e:MouseEvent):void
		{
			
		}
		
		public static function ChangeScreen(screen:int):void
		{
			switch (screen)
			{
				case Screens.INTRO:
					ClearScreen();
					currentScreen = new Intro();
					currentScreen.drawScreen();
					break;
					
				case Screens.MAIN_MENU:
					ClearScreen();
					currentScreen = new  MainMenu();
					currentScreen.drawScreen();
					break;
					
				case Screens.GAME_SCREEN:
					ClearScreen();
					currentScreen = new GameScreen();
					currentScreen.drawScreen();
					break;
					
				case Screens.EDITOR_SCREEN:
					ClearScreen();
					currentScreen = new EditorScreen;
					currentScreen.drawScreen();
					break;
					
			}
		}
		
		private static function ClearScreen()
		{
			if (currentScreen != null)
			_Instance.removeChild(currentScreen);
		}
		
		public function update(e:Event):void
		{
			if (currentScreen != null)
			{
				currentScreen.update();
			}
		}
	}
}